package controllersTest;



import java.awt.List;
import java.util.ArrayList;

import junit.framework.Assert;
import junit.framework.TestCase;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.testng.annotations.Test;

import controllers.*;
import daos.*;
import model.*;

public class ManageStudentControllerTest {

	//private ApplicationContext applicationContext;
	//private ApplicationContext applicationContext;
	//private TimeSlotDAO timeSlotDAO;
	//private StudentProfileDAO studentProfileDAO;
	//private StudentClassDAO studentClassDAO;
	//private CourseDAO courseDAO;
	//private ClassCourseDAO classCourseDAO;
	
	@Test
	public void testCase1()
	{
		/*applicationContext = new ClassPathXmlApplicationContext(new String[] {"classpath:persistenceTest/applicationContext.xml"});
		studentProfileDAO = (StudentProfileDAO)applicationContext.getBean("studentProfileDAO");
		studentClassDAO = (StudentClassDAO)applicationContext.getBean("studentClassDAO");
		 applicationContext = new ClassPathXmlApplicationContext(new String[] {"classpath:persistenceTest/applicationContext.xml"});
			*/

		ManageStudentController createController= new ManageStudentController();
						
	    createController.createStudentProfile("babis Sougias", 12);
	    
	    FindStudentController fs = new FindStudentController();
	    //StudentProfile s = fs.findStudent(14);
	    //System.out.println("Found " + s.getFullName());
	    
	}
	
	
	@Test
	public void testCase2()
	{
		/*applicationContext = new ClassPathXmlApplicationContext(new String[] {"classpath:persistenceTest/applicationContext.xml"});
		studentProfileDAO = (StudentProfileDAO)applicationContext.getBean("studentProfileDAO");
		studentClassDAO = (StudentClassDAO)applicationContext.getBean("studentClassDAO");
		 applicationContext = new ClassPathXmlApplicationContext(new String[] {"classpath:persistenceTest/applicationContext.xml"});
			*/

		ManageStudentController createController= new ManageStudentController();
		FindStudentController fs = new FindStudentController();
		StudentProfile s1 = fs.findStudent(14);
        String InitName= s1.getFullName();
		double gpa1= s1.getGpa();
	    createController.updateStudentProfile(14, "Viki koulianou", 19);
	    	    StudentProfile s2 = fs.findStudent(14);
	    	    String FinalName= s2.getFullName();
	    	    double gpa2= s2.getGpa();

	    System.out.println("O "+InitName+" me gpa "+gpa1+" egine " + FinalName+" me gpa "+gpa2);
	    
	}
	
	@Test
	public void testCase3()
	{
		/*applicationContext = new ClassPathXmlApplicationContext(new String[] {"classpath:persistenceTest/applicationContext.xml"});
		studentProfileDAO = (StudentProfileDAO)applicationContext.getBean("studentProfileDAO");
		studentClassDAO = (StudentClassDAO)applicationContext.getBean("studentClassDAO");
		 applicationContext = new ClassPathXmlApplicationContext(new String[] {"classpath:persistenceTest/applicationContext.xml"});
			*/

		ManageStudentController createController= new ManageStudentController();
		FindStudentController fs = new FindStudentController();
		StudentProfile s1 = fs.findStudent(14);
        Assert.assertNotNull(s1);
	    createController.deleteStudentProfile(14);
	    StudentProfile s2 = fs.findStudent(14);
	    Assert.assertNull(s2);
	   
	    
	}
	
}
